package com.sc.nft.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.sc.nft.entity.EcologyCastExchangeConf;
import com.sc.nft.entity.EcologyHatchExchangeConf;
import com.sc.nft.entity.EcologyHatchMethodConf;
import com.sc.nft.entity.EcologyHatchUsePropsExchange;
import com.sc.nft.mapper.EcologyHatchExchangeConfMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @author 朱梦晨
 * @Description: 生态熔炼上限兑换配置表 数据Dao
 * @date 2024-08-06
 */
@Slf4j
@Repository
public class EcologyHatchExchangeConfDao extends ServiceImpl<EcologyHatchExchangeConfMapper, EcologyHatchExchangeConf> {



    public boolean updateEcologyHatchExchangeConfById(Long id, Boolean sysGiftStatus,Integer giftLimit,Integer giftCount,Boolean status) {
        LambdaUpdateWrapper<EcologyHatchExchangeConf> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(EcologyHatchExchangeConf::getId, id);
        wrapper.set(EcologyHatchExchangeConf::getStatus, status);
        wrapper.set(EcologyHatchExchangeConf::getSysGiftStatus, sysGiftStatus);
        wrapper.set(EcologyHatchExchangeConf::getGiftCount,giftCount);
        wrapper.set(EcologyHatchExchangeConf::getGiftLimit,giftLimit);
        return update(new EcologyHatchExchangeConf(), wrapper);
    }


    /**
     * 获取熔炼上限兑换关联表
     *
     * @param ecologyHatchId
     * @return
     */
    public EcologyHatchExchangeConf getOneByEcologyHatchId(Long ecologyHatchId) {
        LambdaQueryWrapper<EcologyHatchExchangeConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(EcologyHatchExchangeConf::getEcologyHatchId, ecologyHatchId);
        wrapper.eq(EcologyHatchExchangeConf::getIsDelete, Boolean.FALSE);
        return getOne(wrapper);
    }


    /**
     * 获取熔炼上限兑换关联表
     *
     * @param ecologyHatchId
     * @return
     */
    public EcologyHatchExchangeConf getExchangeConfByEcologyHatchId(Long ecologyHatchId) {
        LambdaQueryWrapper<EcologyHatchExchangeConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(EcologyHatchExchangeConf::getEcologyHatchId, ecologyHatchId);
        wrapper.eq(EcologyHatchExchangeConf::getStatus, Boolean.TRUE);
        wrapper.eq(EcologyHatchExchangeConf::getIsDelete, Boolean.FALSE);
        return getOne(wrapper);
    }


    /**
     * 获取全部 已开启赠送熔炼
     *
     * @return
     */
    public List<EcologyHatchExchangeConf> getEcologyHatchGift() {
        LambdaQueryWrapper<EcologyHatchExchangeConf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(EcologyHatchExchangeConf::getSysGiftStatus, Boolean.TRUE);
        wrapper.eq(EcologyHatchExchangeConf::getIsDelete, Boolean.FALSE);
        return list(wrapper);
    }




}
